#pragma once
#include <string>
#include <vector>

struct TimeValue
{
	CString cstrBeginTime;
	CString cstrEndTime;
	int nBeginHour;
	int nBeiginMinute;
	int nEndHour;
	int nEndMinute;
};

struct WeekDayTime
{
	int nWeekIndex;
	std::vector<TimeValue> vecDayTimes;
};

struct WeekDayRect
{
	int nWeekIndex;
	std::vector<CRect> vecDayRects;
};
// CWeekTimePicker

class CWeekTimePicker : public CStatic
{
	DECLARE_DYNAMIC(CWeekTimePicker)

public:
	CWeekTimePicker();
	virtual ~CWeekTimePicker();

	void SetDlgBackColor(COLORREF cBack);
	void SetBarBackColor(COLORREF cBarBack);
	void SetBarSelectColor(COLORREF cBarSelect);
	void SetBarDragColor(COLORREF cBarDrag);
	void SetWeekTime(std::vector<WeekDayTime> &vecWeekTime);
	std::vector<WeekDayTime> GetWeekTime();

protected:
	virtual void PreSubclassWindow();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnPaint();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	afx_msg void OnSize(UINT nType, int cx, int cy);

	DECLARE_MESSAGE_MAP()

	HFONT CreateMyFont(HDC hdc);
	void PaintDC(HDC hdc);
	void SetCtrlSize();
	void UpdateRectArea(HDC hdc, int iWeek);
	void UpdateRectToTime();
	void UpdateTimeToRect();
	void CalcDragFlag(CPoint &point, BOOL bMouseDown);
	void RectToTime(int nDragIndex, CRect& rect, CString& cstrBegin, CString& cstrEnd);

private:
	std::vector<WeekDayTime> m_vecWeekTimes;
	std::vector<CString> m_vecWeekDayName;
	std::vector<CRect> m_vecWeekDayNameRect;
	std::vector<CRect> m_vecWeekDayBarRect;
	std::vector<WeekDayRect> m_vecWeekDayBarSelectedRect;
	BOOL m_bDragBarBorder;
	BOOL m_bDragBar;
	BOOL m_bLButtonDown;
	int m_nLDownX;
	int m_nDragBarIndex;
	BOOL m_bMoveLeft;
	CBrush m_brushDlgBack;
	CBrush m_brushBarBack;
	CBrush m_brushBarSelect;
	CBrush m_brushBarDrag;
	HFONT m_hFont;
	BOOL m_bCanEdit;
	CRect m_rcDragRect;
	TimeValue m_timeValue;
	HCURSOR m_hCursorWE;
	HCURSOR m_hCursorHand;
	HCURSOR m_hCursorArrow;
};


